package com.common.servlet.abstracts;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public abstract class AbstractCronServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public final void doGet(HttpServletRequest request, HttpServletResponse response) {
		boolean isCron = Boolean.parseBoolean(request.getHeader("X-AppEngine-Cron"));
		
		if (isCron) {
			handle();
		}
	}
	
	public final void doPost(HttpServletRequest request, HttpServletResponse response) {
		doGet(request, response);
	}
	
	public abstract void handle();
}
